/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * payOriginalForm.java
 *
 * Created on Oct 22, 2011, 7:16:10 AM
 */
package project;

import Utils.Helper;
import Utils.checkValidate;
import beanControl.payOriginalControl;
import beanInfo.payOriginal;
import javax.swing.JComboBox;

/**
 *
 * @author lyan
 */
public class payOriginalForm extends javax.swing.JFrame {

    payOriginal por = new payOriginal();
    payOriginalControl porict = new payOriginalControl();
    SelectProftle SelectPro;
    String id = "";

    public payOriginalForm(String ID) {
        initComponents();
        this.id = ID;
        lblterm.setText(id);
        txtProfile.setText(id);
        txtbalan.setText(id);
        txtMoney.setText(id);
    }

    public void insertPayOri() {
        por.setPaymentDate(Helper.ConvertDateToString(new java.util.Date()));
        por.setProfileID(Integer.parseInt(txtProfile.getText()));
        por.setPrincipalBalance(txtbalan.getText());
        por.setMoney(txtMoney.getText());
        por.setStatus("False");
        porict.insertpayori(por);
                
        txtMoney.setText("");
        txtProfile.setText("");
        txtbalan.setText("");
        txttotal.setText("");
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    public void loadcbbprofile(JComboBox cbo) {
        String sql = "Select ProfileID,TotalAmount from LoanProfile";
        Helper.getListCBO(sql, cbo, "TotalAmount", "ProfileID");
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        lblterm = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtbalan = new javax.swing.JTextField();
        txtMoney = new javax.swing.JTextField();
        btnSave = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        txtProfile = new javax.swing.JTextField();
        txttotal = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        btnSelect = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBackground(new java.awt.Color(0, 102, 102));
        jPanel1.setLayout(null);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setLayout(null);
        jPanel2.add(lblterm);
        lblterm.setBounds(10, 30, 30, 10);

        jLabel2.setText("ProfileID");
        jPanel2.add(jLabel2);
        jLabel2.setBounds(10, 60, 80, 30);

        jLabel3.setText("PrincipalBalance");
        jPanel2.add(jLabel3);
        jLabel3.setBounds(10, 160, 80, 40);

        jLabel4.setText("Money");
        jPanel2.add(jLabel4);
        jLabel4.setBounds(10, 200, 50, 30);

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 24));
        jLabel5.setForeground(new java.awt.Color(255, 51, 0));
        jLabel5.setText("insert Original");
        jPanel2.add(jLabel5);
        jLabel5.setBounds(90, 10, 200, 30);
        jPanel2.add(txtbalan);
        txtbalan.setBounds(100, 160, 180, 30);
        jPanel2.add(txtMoney);
        txtMoney.setBounds(100, 200, 180, 30);

        btnSave.setText("Save");
        btnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveActionPerformed(evt);
            }
        });
        jPanel2.add(btnSave);
        btnSave.setBounds(110, 260, 57, 23);

        jButton2.setText("Cancel");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel2.add(jButton2);
        jButton2.setBounds(190, 260, 65, 23);

        txtProfile.setEnabled(false);
        jPanel2.add(txtProfile);
        txtProfile.setBounds(100, 60, 180, 30);

        txttotal.setEnabled(false);
        jPanel2.add(txttotal);
        txttotal.setBounds(100, 110, 180, 30);

        jLabel6.setText("totalAmount");
        jPanel2.add(jLabel6);
        jLabel6.setBounds(14, 114, 70, 30);

        btnSelect.setText("Select");
        btnSelect.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSelectActionPerformed(evt);
            }
        });
        jPanel2.add(btnSelect);
        btnSelect.setBounds(290, 60, 61, 30);

        jPanel1.add(jPanel2);
        jPanel2.setBounds(10, 11, 380, 320);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 344, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveActionPerformed
// TODO add your handling code here:
    if (txtbalan.getText().length() == 0) {
        Helper.successMessage("Enter BalanceInteres", "wanning");
    } else if (txtMoney.getText().length() == 0) {
        Helper.successMessage("Enter money", "wanning");
    } else if (checkValidate.checkFloatNumber(txtbalan.getText()) == false) {
        Helper.successMessage("PrincipalBalance is number", "wanning");
    } else if (checkValidate.checkFloatNumber(txtMoney.getText()) == false) {
        Helper.successMessage("Money is number", "wanning");
    } else {
        insertPayOri();
    }

}//GEN-LAST:event_btnSaveActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
    this.dispose();
}//GEN-LAST:event_jButton2ActionPerformed

private void btnSelectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectActionPerformed
// TODO add your handling code here:
    SelectPro = new SelectProftle(null, true, txtProfile, txttotal);
    SelectPro.setVisible(true);


}//GEN-LAST:event_btnSelectActionPerformed
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
//                if ("Nimbus".equals(info.getName())) {
//                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
//                    break;
//                }
//            }
//        } catch (ClassNotFoundException ex) {
//            java.util.logging.Logger.getLogger(payOriginalForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (InstantiationException ex) {
//            java.util.logging.Logger.getLogger(payOriginalForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (IllegalAccessException ex) {
//            java.util.logging.Logger.getLogger(payOriginalForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
//            java.util.logging.Logger.getLogger(payOriginalForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
//        }
//        //</editor-fold>
//
//        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//
//            public void run() {
//                new payOriginalForm().setVisible(true);S
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnSave;
    private javax.swing.JButton btnSelect;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel lblterm;
    private javax.swing.JTextField txtMoney;
    private javax.swing.JTextField txtProfile;
    private javax.swing.JTextField txtbalan;
    private javax.swing.JTextField txttotal;
    // End of variables declaration//GEN-END:variables
}
